package org.bet.utils;

import java.io.Serializable;

import org.springframework.data.mongodb.core.index.Indexed;

public class Range implements Serializable {
	private static final long serialVersionUID = -4622108334859632682L;
	
	@Indexed
	private long start;
	
	@Indexed
	private long end;
	
	public Range(){}
	
	public Range(long start, long end) {
		this.start = start;
		this.end = end;
	}

	public long getStart() {
		return start;
	}

	public void setStart(long start) {
		this.start = start;
	}

	public long getEnd() {
		return end;
	}

	public void setEnd(long end) {
		this.end = end;
	}

	public String toString(){
		return start + "-" + end;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (end ^ (end >>> 32));
		result = prime * result + (int) (start ^ (start >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Range other = (Range) obj;
		if (end != other.end)
			return false;
		if (start != other.start)
			return false;
		return true;
	}

	public long length() {
		return end - start;
	}
	
	
}
